//
//  ExperienceAnotherCell.m
//  PaiLeXiongProject
//
//  Created by 小獾科技 on 2017/8/25.
//  Copyright © 2017年 小獾科技. All rights reserved.
//

#import "ExperienceAnotherCell.h"


@interface ExperienceAnotherCell ()

@property (nonatomic, strong) UIImageView *imgView;
@property (nonatomic, strong) UILabel *titleLable;
@property (nonatomic, strong) UILabel *reminderLabel;//申请成功  正在审核  未通过
@property (nonatomic, strong) UILabel *dateLabel;
@property (nonatomic, strong) UIImageView *litleImg;

@end
@implementation ExperienceAnotherCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        self.separatorInset = UIEdgeInsetsMake(0, 0, 0, 0);
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        _imgView = [UIImageView new];
        [self addSubview:_imgView];
        [_imgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self).offset(10);
            make.left.equalTo(self).offset(10);
            make.width.equalTo(@90);
            make.height.equalTo(@90);
        }];
        
        _litleImg = [UIImageView new];
        [_imgView addSubview:_litleImg];
        [_litleImg mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_imgView).offset(-2);
            make.left.equalTo(_imgView).offset(9);
            make.width.equalTo(@30);
            make.height.equalTo(@14);
        }];
        
        _titleLable = [UILabel new];
        _titleLable.text = @"爱儿美儿童摄影秋季梦想儿童摄影秋季梦想秋季梦想";
        _titleLable.textColor = ColorFrom16(0x323232);
        _titleLable.font = PFRFONT(14);
        _titleLable.numberOfLines = 2;
        [self addSubview:_titleLable];
        [_titleLable mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.top.equalTo(self).offset(8);
            make.top.equalTo(_imgView);
            make.left.equalTo(_imgView.mas_right).offset(10);
            make.right.equalTo(self).offset(-10);
//            make.height.equalTo(@40);
            make.height.greaterThanOrEqualTo(@20);
        }];
        
        _reminderLabel = [UILabel new];
        _reminderLabel.text = @"申请成功";
        _reminderLabel.textColor = ColorFrom16(0xff8ca2);
        _reminderLabel.font = PFRFONT(11);
        [self addSubview:_reminderLabel];
        [_reminderLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_imgView.mas_right).offset(10);
            make.top.equalTo(_titleLable.mas_bottom).offset(22);
            make.width.greaterThanOrEqualTo(@70);
            make.height.equalTo(@16);
        }];
        
        _dateLabel = [UILabel new];
        _dateLabel.text = @"申请日期：2017年3月27日";
        _dateLabel.textColor = ColorFrom16(0xa4a4a4);
        _dateLabel.font = PFRFONT(9);
        [self addSubview:_dateLabel];
        [_dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_reminderLabel.mas_bottom).offset(4);
            make.left.equalTo(_reminderLabel);
            make.width.greaterThanOrEqualTo(@120);
            make.height.equalTo(@13);
        }];
        
        _codeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_codeBtn setTitle:@"查看二维码" forState:0];
        [_codeBtn setTitleColor:ColorFrom16(0xffffff) forState:0];
        _codeBtn.layer.backgroundColor = ColorFrom16(0xff5b7a).CGColor;
        _codeBtn.layer.cornerRadius = 4;
        _codeBtn.titleLabel.font = PFRFONT(12);
        [self addSubview:_codeBtn];
        [_codeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(self).offset(-10);
            make.right.equalTo(self).offset(-10);
            make.width.equalTo(@80);
            make.height.equalTo(@26);
        }];
        
    }
    return self;
}

- (void)configViewWithModel:(ExperienceApplyModel *)model
{
    _titleLable.text = model.goods_name;
    _reminderLabel.text = model.status_text;
    [_imgView sd_setImageWithURL:[NSURL URLWithString:model.goods_img] placeholderImage:nil];
    _dateLabel.text = [NSString stringWithFormat:@"申请日期：%@", model.applytime];
    [_litleImg sd_setImageWithURL:[NSURL URLWithString:model.label_url]];
    if([[NSString stringWithFormat:@"%@", model.status_val] isEqualToString:@"2"])
    {
        self.codeBtn.backgroundColor = ColorFrom16(0xff5b7a);
    }
    else
    {
        self.codeBtn.backgroundColor = ColorFrom16(0xEAEAEA);
    }
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
